package com.icbc.digitalwallet.common.util;

import io.swagger.models.auth.In;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Dictionary;
import java.util.HashMap;


/**
 * 获取日期的年份，月份和星期
 */
public class GetYearMonthWeek {

    private static final HashMap<Integer, String> map = new HashMap<>();

    static {
        map.put(1,"周一");
        map.put(2,"周二");
        map.put(3,"周三");
        map.put(4,"周四");
        map.put(5,"周五");
        map.put(6,"周六");
        map.put(7,"周七");
    }

    /**
     * 获取日期的年份和月份
     * @param localDateTime
     * @return
     */
    public static String getYearMonth(LocalDateTime localDateTime){
        int year = localDateTime.getYear();
        int month = localDateTime.getMonthValue();
        String r = year + "年" + month + "月";
        return r;
    }


    /**
     * 获取日期年份
     * @param localDateTime
     * @return
     */
    public static Integer getYear(LocalDateTime localDateTime){
        int year = localDateTime.getYear();
        return year;
    }


    /**
     * 获取日期月份
     * @param localDateTime
     * @return
     */
    public static Integer getMonth(LocalDateTime localDateTime){
        int month = localDateTime.getMonthValue();
        return month;
    }



    public static Integer getDay(LocalDateTime localDateTime){
        int day = localDateTime.getDayOfMonth();
        return day;
    }

    /**
     * 获取日期的星期
     * @param localDateTime
     * @return
     */
    public static String getWeek(LocalDateTime localDateTime){
        int week = localDateTime.getDayOfWeek().getValue();
        String r = map.get(week);
        return r;
    }
}
